
package org.skill.panel;

import com.tool.role.RoleData;
import com.tool.role.SkillUtil;
import com.updateNew.MyIsif;

import java.awt.LayoutManager;
import java.math.BigDecimal;
import javax.swing.JPanel;
import org.come.bean.PrivateData;
import org.come.until.AnalysisString;

public class SkillSMGatePanel extends JPanel {
    private SkillSMPanel[] skillSMPanels;

    public SkillSMGatePanel() {
        if("水墨UI".equals(MyIsif.getStyle())) {
            this.setBounds(49, 78, 600, 300);
        }else{
            this.setBounds(25, 78, 523, 309);
        }
    	this.setOpaque(false);
    	this.setLayout((LayoutManager)null);
    	this.skillSMPanels = new SkillSMPanel[3];
        for(int i = 0; i < this.skillSMPanels.length; ++i) {
            this.skillSMPanels[i] = new SkillSMPanel(i);
            this.add(this.skillSMPanels[i]);
        }

    }

    public void getRaceSkillPanel(BigDecimal raceId, String sex) {
        String skillName;
        if (raceId.compareTo(new BigDecimal("10001")) == 0) {
            if (sexisMan(sex)) {
                skillName = "冰|睡|混";
                String skillAddress = "大唐官府|方寸山|化生寺";
                changeSkillBar(skillName, skillAddress);
            } else {
                skillName = "冰|睡|毒";
                String skillAddress = "大唐官府|方寸山|女儿村";
                changeSkillBar(skillName, skillAddress);
            }
        } else if (raceId.compareTo(new BigDecimal("10002")) == 0) {
            if (sexisMan(sex)) {
                skillName = "慑|牛|速";
                String skillAddress = "幽冥地府|魔王寨|狮驼岭";
                changeSkillBar(skillName, skillAddress);
            } else {
                skillName = "慑|牛|盘";
                String skillAddress = "幽冥地府|魔王寨|盘丝洞";
                changeSkillBar(skillName, skillAddress);
            }
        } else if (raceId.compareTo(new BigDecimal("10003")) == 0) {
            if (sexisMan(sex)) {
                skillName = "雷|水|风";
                String skillAddress = "天宫|龙宫|五庄观";
                changeSkillBar(skillName, skillAddress);
            } else {
                skillName = "雷|水|火";
                String skillAddress = "天宫|龙宫|普陀山";
                changeSkillBar(skillName, skillAddress);
            }
        } else if (raceId.compareTo(new BigDecimal("10004")) == 0) {
            if (sexisMan(sex)) {
                skillName = "忘|冥|蛊";
                String skillAddress = "兰若寺|白骨洞|三尸派";
                changeSkillBar(skillName, skillAddress);
            } else {
                skillName = "忘|冥|魅";
                String skillAddress = "兰若寺|白骨洞|阴都";
                changeSkillBar(skillName, skillAddress);
            }
        } else if (raceId.compareTo(new BigDecimal("10005")) == 0) {
            if (sexisMan(sex)) {
                skillName = "霹|霖|摇";
                String skillAddress = "流洲|蓬莱|方壶";
                changeSkillBar(skillName, skillAddress);
            } else {
                skillName = "霹|霖|沧";
                String skillAddress = "流洲|蓬莱|瀛洲";
                changeSkillBar(skillName, skillAddress);
            }
        }

    }

    public static boolean sexisMan(String sex) {
        return "男".equals(sex);
    }

    public void changeSkillBar(String skillName, String skillAddress) {
		String[] skillNames = skillName.split("\\|");
        String[] skillAddresss = skillAddress.split("\\|");
		PrivateData data = RoleData.getRoleData().getPrivateData();
		String[] skills = data.getSkill("S");
		// 得出当前人物几转
		int lvltrue = AnalysisString.lvltrue(RoleData.getRoleData().getLoginResult().getGrade());

		for (int i = 0; i < skillNames.length; i++) {
			skillSMPanels[i].getSkillTitle().setText(skillNames[i]);
            skillSMPanels[i].getSkillAddress().setText(skillAddresss[i]);
			skillSMPanels[i].getSkillsName(SkillUtil.getSkillsAll(skillNames[i]), lvltrue, skills);
        }

    }
}
